package com.suse.service.community.config;

import com.suse.service.community.mapper.DiscussPostMapper;
import com.suse.service.community.repository.DiscussPostRepository;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * <p>
 * ES初始化配置类
 * </p>
 *
 * @author 辜玉彬
 * @since 2022-09-09 12:47
 */
// 部署的时候放开以下注释
// @Configuration
public class EsInitConfig {

    @Resource
    private DiscussPostMapper discussPostMapper;

    @Resource
    private DiscussPostRepository discussPostRepository;

    @PostConstruct
    public void init() {
        // 初始化 ES 数据
        discussPostRepository.saveAll(discussPostMapper.selectAll());
    }

}
